﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using EYDIngenieria.ERP.ObjetosDeNegocio.Dominio;

public partial class impresiones_OrdenDeCompra : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        OrdenDeCompra oc = (OrdenDeCompra)Session["ORDENDECOMPRA"];

        txbFecha.Text = oc.Fecha.ToShortDateString();
        txbNumeroOc.Text = oc.Id.ToString();
        txbProveedor.Text = oc.Proveedor.RazonSocial;
        txbMontoTotal.Text = oc.MontoTotal.ToString();
        txbCuentaCorriente.Text = oc.CuentaCorrientee == null ? string.Empty : oc.CuentaCorrientee.Descripcion;
        txbNumeroDeCheque.Text = oc.NumeroCheque.ToString();
        gdvDetalleOC.DataSource = oc.Detalle;
        gdvDetalleOC.DataBind();
        SeteaTotal(oc);
    }

    private void SeteaTotal(OrdenDeCompra oc)
    {
        double montoTotal = 0;
        foreach (DetalleOrdenDeCompra d in oc.Detalle)
        {
            montoTotal = montoTotal + d.ValorTotal;
        }
        ((Label)gdvDetalleOC.FooterRow.FindControl("lblTotal")).Text = montoTotal.ToString();
    }



   
}
